<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      ul {
        list-style: none;
      }
      div {
        width: 1200px;
        height: 400px;
        margin: 50px auto;
        border: 1px solid red;
        overflow: hidden;
        ul {
          li {
            width: 240px;
            height: 400px;
            float: left;
            list-style-type: none;
          }
        }
      }
    </style>
  </head>
  <body>
    <div>
      <ul id="box">
        <li><img src="./images/1.webp" alt="" /></li>
        <li><img src="./images/2.webp" alt="" /></li>
        <li><img src="./images/3.webp" alt="" /></li>
        <li><img src="./images/4.webp" alt="" /></li>
        <li><img src="./images/5.webp" alt="" /></li>
      </ul>
    </div>

    <script>
      window.onload = function () {
        var ul = document.getElementById("box");
        let lis = ul.children;
        for (var i = 0; i < lis.length; i++) {
          //排他思想 :移入把所有的li标签宽度改为100，把自己改为800
          lis[i].onmouseenter = function (e) {
            for (var j = 0; j < lis.length; j++) {
              lis[j].style.width = "100px";
            }
            this.style.width = "800px";
            this.style.transition = "2s";
          };
        }
        ul.onmouseleave = function () {
          for (let j = 0; j < lis.length; j++) {
            lis[j].style.width = "240px";
          }
        };
      };
    </script>
  </body>
</html>
